package com.os.opencv.java.chapter7;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Point;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

public class MorphologyEx3 {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        //读取图像并在屏幕上显示
        Mat src = Imgcodecs.imread("/Users/matt/Pictures/111.jpg", Imgcodecs.IMREAD_GRAYSCALE);
        HighGui.imshow("src1", src);
        HighGui.waitKey(0);

        //形态学梯度并在屏幕上显示
        Point anchor = new Point(-1,-1);
        Mat dst = new Mat();
        Imgproc.morphologyEx(src, dst, Imgproc.MORPH_GRADIENT, new Mat(), anchor, -1);
        HighGui.imshow("grandient1", dst);
        HighGui.waitKey(0);

        //读取图像2并在屏幕上显示
        src = Imgcodecs.imread("/Users/matt/Pictures/1040g2h030o8vt6sf2m5g5ngomtj09etmlpmv37g!nd_whlt34_webp_wm_1.jpg", Imgcodecs.IMREAD_GRAYSCALE);
        HighGui.imshow("src2", src);
        HighGui.waitKey(0);

        //形态学梯度并在屏幕上显示
        Imgproc.morphologyEx(src, dst, Imgproc.MORPH_GRADIENT, new Mat(), anchor, 1);
        HighGui.imshow("gradient2", dst);
        HighGui.waitKey(0);

        System.exit(0);
    }
}
